#include<iostream>
#include<string>
using namespace std;
class Solution
{
public:
    string compressString(string S)
    {
        string str;
        int len = S.size();
        for (int i = 0; i < S.size(); i++)
        {
            str += S[i];
            int count = 1;
            while (S[i] == S[i + 1])
            {
                count++;
                i++;
            }
            str += to_string(count);
        }
        return len <= str.size() ? S : str;
    }
};

int main()
{
    string str("aaabbcccddeeeeaaaa");
    Solution s;
    string sstr=s.compressString(str);
    cout << sstr << endl;
    return 0;
}